package com.square.service.common.exception;

import com.baomidou.mybatisplus.extension.api.IErrorCode;
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
import com.square.service.common.consts.GlobalStatusCode;
import com.square.service.common.handler.ApiCode;


/**
 * @author : 王苏
 * @date : 2020/8/11 16:41
 * @description : 数据库异常
 */
public class DatabaseException extends ApiException {

    public DatabaseException() {
        super(ApiCode.DATABASE_EXCEPTION);
    }

    public DatabaseException(String msg) {
        super(new IErrorCode() {
            @Override
            public long getCode() {
                return GlobalStatusCode.DATABASE_EXCEPTION;
            }

            @Override
            public String getMsg() {
                return msg;
            }
        });
    }

    public DatabaseException(long code, String msg) {
        super(new IErrorCode() {
            @Override
            public long getCode() {
                return code;
            }

            @Override
            public String getMsg() {
                return msg;
            }
        });
    }

}
